package com.acme.bankapp.account;


/**
 * @author Andrey Alekov
 * Saving account implementation
 */
public class SavingAccount extends AbstractAccount{

	/*
	 * Constructor
	 * @param amount to initial balance value
	 */
	public SavingAccount(double amount) throws IllegalArgumentException {
		super(amount);
	}

	@Override
	public void deposit(double amount) {
		balance += amount;
	}

	@Override
	public void withdraw(double amount) throws OverDraftLimitExceededException, 
	NotEnoughFundsException {
		if (balance < Math.abs(amount)){
			throw new NotEnoughFundsException("Account limit exceeded. "
					+ "Avaliabale balance " + this.balance);
		}
		balance -= amount;
	}

	@Override
	public double maximumAmountToWithdraw() {
		return balance;
	}

}
